package com.simple.portal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.simple.base.dao.BaseDAO;
import com.simple.portal.dao.IAccountDAO;
import com.simple.portal.vo.AccountVO;
import com.simple.util.common.Constants;

@Repository("accountDAO")
public class AccountDAOImpl extends BaseDAO implements IAccountDAO {

	@Override
	public AccountVO findById(final String id) {
		return  super.get(AccountVO.class,id);
	}

	@Override
	public void save(final AccountVO accountVO,final String operator) {
		AccountVO tempAccountVO = super.save(accountVO);
		super.saveLogger(operator, tempAccountVO, tempAccountVO.getAccountId(),Constants.LOGGER_OPERATE_FLAG_ADD);
	}

	@Override
	public void update(final AccountVO accountVO,final String type,final String operator) {
		super.update(accountVO);
		super.saveLogger(operator, accountVO, accountVO.getAccountId(),type);
	}
	
	@Override
	public List<AccountVO> findAll() {
		return super.query(AccountVO.class);
	}

	@Override
	public void delete(final AccountVO accountVO,final String operator) {
		super.delete(accountVO);
		super.saveLogger(operator, accountVO, accountVO.getAccountId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

	@Override
	public void delete(final String id,final String operator) {
		AccountVO accountVO = findById(id);
		super.delete(AccountVO.class,id);
		super.saveLogger(operator, accountVO, accountVO.getAccountId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

}
